package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class Customer {
    private Long id;
    //姓名
    private String name;
    //年龄
    private Integer age;
    //性别
    private Integer gender;
    //电话
    private String tel;
    //qq
    private String qq;

    /**
     * 关联属性 4个
     */
    //职业
    private SystemDictionaryItem job;
    //来源
    private SystemDictionaryItem source;
    //销售人员
    private Employee seller;
    //录入人员
    private Employee inputuser;

    //录入时间
    private Date inputTime;
    //当前状态
    private Integer status = STATUS_POTENTIAL;//0

    public static final int GENDER_FEMALE = 0; // 女
    public static final int GENDER_MALE = 1; // 男

    public static final int STATUS_POTENTIAL = 0;  // 潜在
    public static final int STATUS_FORMAL = 1;  // 正式
    public static final int STATUS_POOL = 2;  // 资源池
    public static final int STATUS_FAILURE = 3;  // 失败
    public static final int STATUS_LOST = 4;  // 流失

    public String getGenderName() {
        switch (this.gender) {
            case GENDER_FEMALE:
                return "女";
            case GENDER_MALE:
                return "男";
            default:
                return "未知";
        }
    }

    public String getStatusName() {
        switch (this.status) {
            case STATUS_POTENTIAL:
                return "潜在";
            case STATUS_FORMAL:
                return "正式";
            case STATUS_POOL:
                return "资源池";
            case STATUS_FAILURE:
                return "失败";
            case STATUS_LOST:
                return "流失";
            default:
                return "未知";
        }
    }

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", this.id);
        map.put("name", this.name);
        map.put("age", this.age);
        map.put("gender", this.gender);
        map.put("tel", this.tel);
        map.put("qq", this.qq);
        map.put("status", this.status);
        if (this.job != null) {
            map.put("jobId", this.job.getId());
        }
        if (this.source != null) {
            map.put("sourceId", this.source.getId());
        }
        if (this.seller != null) {
            map.put("sellerId", this.seller.getId());
            map.put("sellerName", this.seller.getName());
        }
        return JSON.toJSONString(map);
    }

}